﻿using System;
using System.Collections.Generic;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.IO;

public partial class ajaxUpload : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e) {
        HttpFileCollection files = Request.Files;
        if (files != null && files.Count > 0) {
            HttpPostedFile file = files[0];
            string tmpPath = Server.MapPath("~/Upload/");
            string fileName = Path.GetFileNameWithoutExtension(file.FileName);//Path.GetFileName(file.FileName);
            string extName = Path.GetExtension(file.FileName);
            extName = extName.Trim('.');
            string newfileName = DateTime.Now.ToString("yyyyMMddhhmmssffffff") + "." + extName;
            try {
                file.SaveAs(tmpPath + newfileName);
                Response.Write(newfileName);
                

            }
            catch (Exception ex) {
                Response.Write("");
            }
            Response.End();
        }
    }
}